<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<title>notice demo </title>
<link type="text/css" rel="stylesheet"  href="../highlight/shCore.css"/>
<link type="text/css" rel="stylesheet" href="../style/avalon.doc.css"/>
<script src="../highlight/shCore.js"></script>
<script src="../avalon.js"></script>
</head>
<body>
    <div class="wrapper">
        <h1>notice demo</h1>
        <p class="example">notice的show和hide回调</p>
        <div ms-skip>
            <pre class="brush: js; html-script: true; gutter: false; toolbar: false">
                &lt;!DOCTYPE HTML&gt;
                &lt;html&gt;
                &lt;head&gt;
                    &lt;meta charset='utf-8'/&gt;
                    &lt;title&gt;notice demo 1&lt;/title&gt;
                    &lt;script src='avalon.js'&gt;&lt;/script&gt;
                &lt;/head&gt;
                &lt;body&gt;
                    &lt;div class="demo-show" ms-controller="noticeDemo"&gt;
                        &lt;div ms-widget="notice,a,$aOpts"&gt;此demo用来演示notice的onHide、onShow回调方法的使用,请打开控制台查看回调执行情况&lt;/div&gt;
                        &lt;button ms-click="toggleNotice('a')"&gt;toggle notice a&lt;/button&gt;
                        &lt;script&gt;
                            require(["notice/avalon.notice"], function(avalon) {
                                var model = avalon.define("noticeDemo", function(vm) {
                                    var number = 0;
                                    vm.$aOpts = {
                                        onHide: function() {
                                            number++;
                                            avalon.vmodels.a.content = "隐藏notice后在回调里将其content修改这是第&nbsp;&nbsp;&lt;b style='color:blue'&gt;"+number+"&lt;/b&gt;&nbsp;&nbsp;次修改"
                                            avalon.log("隐藏notice后的回调");
                                        },
                                        onShow: function() {
                                            var typeArr = ["info", "success", "error"];
                                            var index = Math.floor(Math.random()*3)
                                            avalon.vmodels.a.type = typeArr[index];
                                            avalon.log("显示notice后的回调中切换notice的类型");
                                        }
                                    }
                                    vm.toggleNotice = function(id) {
                                        var noticeVm = avalon.vmodels[id]
                                        noticeVm.toggle = !noticeVm.toggle
                                    }
                                })
                                avalon.scan();
                            })
                        &lt;/script&gt;
                    &lt;/div&gt;
                &lt;/body&gt;
                &lt;/html&gt;
            </pre>
        </div>
        <div class="demo-show" ms-controller="noticeDemo">
            <div ms-widget="notice,a,$aOpts">此demo用来演示notice的onHide、onShow回调方法的使用,请打开控制台查看回调执行情况</div>
            <button ms-click="toggleNotice('a')">toggle notice a</button>
            <script>
                require(["notice/avalon.notice"], function(avalon) {
                    var model = avalon.define("noticeDemo", function(vm) {
                        var number = 0;
                        vm.$aOpts = {
                            onHide: function() {
                                number++;
                                avalon.vmodels.a.content = "隐藏notice后在回调里将其content修改这是第&nbsp;&nbsp;<b style='color:blue'>"+number+"</b>&nbsp;&nbsp;次修改"
                                avalon.log("隐藏notice后的回调");
                            },
                            onShow: function() {
                                var typeArr = ["info", "success", "error"];
                                var index = Math.floor(Math.random()*3)
                                avalon.vmodels.a.type = typeArr[index];
                                avalon.log("显示notice后的回调中切换notice的类型");
                            }
                        }
                        vm.toggleNotice = function(id) {
                            var noticeVm = avalon.vmodels[id]
                            noticeVm.toggle = !noticeVm.toggle
                        }
                    })
                    avalon.scan();
                })
            </script>
        </div>
    </div>
</body>
</html>